﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using Maria.Common.Aspects;
using Microsoft.Practices.Unity;
using RG.Common.Configuration;
using RG.Common.Export;
using RG.Common.WPF;
using RG.Common;
using RG.Common.WPF.BaseFrame;
using RG.Common.WPF.Workplaces;
using RG.Consts;
using RealtorGuide.Classes;

namespace RG.Frames
{
    [Common.SupportDataBinding]
    public class ManagersFrameVM :
        BaseListFrameVM<ManagersFrameVM, Manager, Manager, IManagerService, ManagersQueryParams>,
        IFrameForMultiWorkplace
    {
        [InjectionConstructor]
        public ManagersFrameVM(IUnityContainer cfg)
            : base(cfg)
        {
            Name = "Менеджеры";
        }

        protected override void InitButtons(ObservableCollection<IToolbarButton> buttons)
        {
            buttons.AddRange(new List<IToolbarButton>
                       {
                           new RefreshButton(Refresh),
                           new AddButton(Add),
                           new EditButton(Edit),
                         
                       });
        }

        private void Add()
        {

        }

        private void Edit()
        {

        }

        protected override void InitColumns(ObservableCollection<IColumnInfo> columns)
        {
            columns.AddRange(new List<IColumnInfo>()
                                 {
                                     new ColumnInfoInt<Manager>("Код", 50, x => x.Id),
                                     new ColumnInfoString<Manager>("ФИО", 150, x => x.FIO),
                                     new ColumnInfoString<Manager>("Телефон", 150, x => x.Phone),
                                     new ColumnInfoString<Manager>("Заметки", 300, x => x.Notes),
                                 });
        }

        /// <summary>
        /// Перегружаем этот метод для заполнения параметров запроса из фильтров
        /// </summary>
        protected override ManagersQueryParams InitQueryParam()
        {
            return new ManagersQueryParams();
        }

        protected override Manager fromDTO(Manager dto)
        {
            return dto;
        }

        public bool CanClose
        {
            get { return true; }
        }

        public string Name { get; set; }
    }
}
